package flink.examples;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.datastream.SideOutputDataStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import org.apache.flink.util.OutputTag;

public class SplitStreamByFilter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env =
                StreamExecutionEnvironment.getExecutionEnvironment();
        SingleOutputStreamOperator<Integer> ds =
                env.socketTextStream("192.168.111.128", 7000)
                        .map(Integer::valueOf);
        SingleOutputStreamOperator<Integer> ds1 = ds.filter(x ->
                x % 2 == 0);
        SingleOutputStreamOperator<Integer> ds2 = ds.filter(x ->
                x % 2 == 1);
        ds1.print("偶数");
        ds2.print("奇数");
        env.execute();
    }
}